package com.sun.dream.fish.util;

import jakarta.servlet.http.HttpServletRequest;

import java.util.Enumeration;

/**
 * Description:  Http请求处理工具
 * Created By ljl on 2023/12/05.
 */
public class HttpUtil {

    public HttpUtil() {
    }

    public static final String getHeader(HttpServletRequest request, String header, String defaultValue) {
        Enumeration<String> headerNames = request.getHeaderNames();
        if (headerNames == null) {
            return defaultValue;
        } else {
            while (headerNames.hasMoreElements()) {
                if (headerNames.nextElement().equalsIgnoreCase(header)) {
                    return request.getHeader(header);
                }
            }
        }
        return defaultValue;
    }
}
